//
//  KLWebViewController.m
//  Koala
//
//  Created by cao pan on 11/23/14.
//  Copyright (c) 2014 Anonymous. All rights reserved.
//

#import "KLWebViewController.h"

@interface KLWebViewController ()<UIWebViewDelegate>

@end

@implementation KLWebViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self setTitle:@"Detail"];
    }
    return self;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setLeftButton:nil normalImage:@"btn_back_normal" highlightImage:@"btn_back_press"] ;
}



- (void)setMainDataModel:(KLMainDataModel *)mainDataModel
{
    self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    [self.webView setDelegate:self];
    [self.webView setBackgroundColor:[UIColor clearColor]];
    [self.webView scalesPageToFit];
    [self.view addSubview:self.webView];
    NSString * urlStr = mainDataModel.hrefStr;
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]];
}


- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [self networkRequestStart];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self networkRequestFinish];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [self networkRequestFinish];
    NSLog(@"webView --------- %@",error);
}



@end
